package vista;

import daoBeans.conexionMySql;
import daoBeans.daoUsuario;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import modelo.Usuario;

@ManagedBean
@ApplicationScoped
public class adminprincipalempresaniBean {

    private String nombreGerente;
    private String idGerente;
    private conexionMySql sql;
    private daoUsuario daou;
    private Statement st;
    Connection mysql;
    Usuario other = new Usuario();

    public void init(){        
        sql = new conexionMySql();   
        mysql = sql.comenzarDb();
        daou = new daoUsuario(mysql);
        
    }

    public String getIdGerente() {
        return idGerente;
    }

    public void setIdGerente(String idGerente) {
        this.idGerente = idGerente;
    }

    public String getNombreGerente() {
        return nombreGerente;
    }

    public void setNombreGerente(String nombreGerente) {
        this.nombreGerente = nombreGerente;
    }    
    
    public void crearGerente() {
        try {
         st = mysql.createStatement();
         st.executeQuery("INSERT INTO gerente "+"VALUES ('"+getIdGerente()+"',"+"'"+getNombreGerente()+"');");
        }catch (SQLException ex) {
            Logger.getLogger(loginBean.class.getName()).log(Level.SEVERE, null, ex);
        }
  }
    
    public void buscarGerente() {
        try {
         st = mysql.createStatement();
         st.executeQuery("SELECT * FROM gerente "+"WHERE id="+getIdGerente()+"OR nombre="+getNombreGerente());
        }catch (SQLException ex) {
            Logger.getLogger(loginBean.class.getName()).log(Level.SEVERE, null, ex);
        }
  }
    
  public void borrarGerente() {
        try {
         st = mysql.createStatement();
         st.executeQuery("DELETE FROM gerente "+"WHERE id="+getIdGerente()+"OR nombre="+getNombreGerente());
        }catch (SQLException ex) {
            Logger.getLogger(loginBean.class.getName()).log(Level.SEVERE, null, ex);
        }
  }


    



}